package com.haoji.upload.common.interceptor;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @program: upload
 * @description:
 * @author: xiaolei
 * @create: 2021-04-16 15:55
 **/
public class CommonInterceptor extends HandlerInterceptorAdapter {

    /**
     * Controller控制器执行之前，
     * @param request
     * @param response
     * @param handler
     * @return
     * @throws Exception
     */
    public  boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
            throws Exception {
        //true就是放行，原来执行那个
        //controller接着执行那个controller
        //false终止原来的请求
        return true;
    }
    /*
     * Controller控制器执行之后，
     * 视图渲染之前做的操作
     */
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
                           ModelAndView modelAndView) throws Exception {
    }
    /*
     * 在视图解析器渲染视图之后的操作
     */
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
            throws Exception {

    }

}
